<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('机构学生信息列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <!--<li>
                            <label>家长id：</label>
                            <input type="text" name="suId"/>
                        </li>-->
                        <li>
                            <label>学生姓名：</label>
                            <input type="text" name="stuName" placeholder="姓名为2-4个字"/>
                        </li>
                        <!--<li>
                            <label>学生备注：</label>
                            <input type="text" name="stuRemark"/>
                        </li>-->
                        <li>
                            <label>学生年级：</label>
                            <input type="text" name="stuGrade" placeholder="请输入整数"/>
                        </li>
                        <li>
                            <label>所在学校：</label>
                            <input type="text" name="stuSchool" placeholder="请输入所在学校"/>
                        </li>
                        <li>
                            <label>学生年纪：</label>
                            <input type="text" name="stuAge" placeholder="请输入学生年纪"/>
                        </li>
                        <li>
                            <label>学生性别：</label>
                            <select name="stuGender">
                                <option value="">--请选择性别--</option>
                                <option value="1">男</option>
                                <option value="0">女</option>
                            </select>
                        </li>
                        <li>
<!--                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>-->
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="submitHandler()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="itsystem:student:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="itsystem:student:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="itsystem:student:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="itsystem:student:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('itsystem:student:edit')}]];
    var removeFlag = [[${@permission.hasPermi('itsystem:student:remove')}]];
    var prefix = ctx + "itsystem/student";
    $("#formId").validate({
        focusCleanup: true,
        //添加学生表单校验规则
        rules: {
            suId: { //家长id
                digits: true//是整数
            }
            , stuName: {//姓名
                isName: true,//为2-4个汉字
                maxlength: 5//最大长度为5
            }
            , stuGrade: {//年级
                digits: true,//是整数
                maxlength: 5//长度不能大于5
            }
            , stuSchool: {//学校
                maxlength: 20//长度最大为5位数
            }
            , stuAge: {//年纪
                range:[1,60]//年纪在1-60之间
            },
        }
    });

    //提交处理器
    function submitHandler() {
        //验证搜索项
        if ($.validate.form()) {
            //检索
            $.table.search();
        }
    }

    $(function() {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "机构学生信息",
            columns: [{
                checkbox: true
            },
                {
                    field: 'stuId',
                    title: '学生标识ID',
                    visible: false
                },
                /*{
                    field: 'suId',
                    title: '家长id'
                },*/
                {
                    field: 'stuName',
                    title: '学生姓名'
                },
                {
                    field: 'stuRemark',
                    title: '学生备注',
                    visible: false
                },
                {
                    field: 'stuGrade',
                    title: '学生年级'
                },
                {
                    field: 'stuSchool',
                    title: '所在学校'
                },
                {
                    field: 'stuAge',
                    title: '学生年纪'
                },
                {
                    field: 'stuGender',
                    title: '学生性别'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.stuId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.stuId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });
</script>
</body>
</html>